package qc.module.ehs.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import qc.module.ehs.dto.taskitem.TaskItemInfoDto;
import qc.module.ehs.entity.EhsTaskItem;

import java.util.List;

/**
 * EhsTaskItemMapper
 *
 * @author QuCheng Tech
 * @since 2024/11/13
 */
@Mapper
public interface EhsTaskItemMapper {
    EhsTaskItemMapper MAPPER = Mappers.getMapper(EhsTaskItemMapper.class);

    @Mapping(target = "planbegintm", source = "planbegintm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "planendtm", source = "planendtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "execendtm", source = "execendtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "latestexecbegintm", source = "latestexecbegintm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "latestexecendtm", source = "latestexecendtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "itemname",source = "itemname")
    @Mapping(target = "tasktype", source = "tasktype.index")
    @Mapping(target = "planfrequencytype", source = "planfrequencytype.index")
    @Mapping(target = "transreceivetm", source = "transreceivetm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    TaskItemInfoDto toDto(EhsTaskItem en);
    
    List<TaskItemInfoDto> toDtoList(List<EhsTaskItem> ens);
}